<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				userCacheKey:"hr-xz-tsalaydjustMulti-empInfo-user-cache"
			})
		},
		methods:{
			inputAdjustLimit(val){
				let _that = this
				let befor = _that.$refs.autoform.formdata.origSalary 
				 _that.$refs.autoform.formdata.monthSalaryStandard = Number(befor)+Number(val)
			},
			getSalaryLeveList(){
				let _that = this
				_that.om.request(
					"tsysdict/getListByCode",
					{
						code:"23645"
					}
				).then(res=>{
					_that.$refs.autoform.changeEditor("empInfo","salaryLevelId","data",configSelectData(res,"id","dicname"))
					_that.$refs.autoform.initSelectIndex("empInfo","salaryLevelId")
				})
			},
			onSelectSalaryLevel(item){
				let _that = this
				_that.om.request(
					"salaryStandard/getSalaryRange1",
					{
						posId: _that.$refs.autoform.formdata.salaryPosId,
						levelId: item.id
					},
					"post"
				).then(res=>{
					_that.$refs.autoform.formdata.levelSalaryRange = res.value.str
					_that.$refs.autoform.clear("empInfo","monthSalaryStandard")
					_that.$refs.autoform.clear("empInfo","adjustLimit")
					
				})
			},
			afterUser(id){
				let _that = this
				_that.om.request(
					"tsalaryAdjustMulti/afterUser",
					{
						userId:id
					}
				).then(res=>{
					_that.$refs.autoform.formdata.salaryPosName = res.value.salaryPosName
					_that.$refs.autoform.formdata.salaryPosId = res.value.salaryPosId
					_that.$refs.autoform.formdata.salaryWay = res.value.salaryWay
					_that.$refs.autoform.formdata.entryDate = res.value.entryDate
					_that.$refs.autoform.formdata.posGradeName = res.value.posGradeName
					_that.$refs.autoform.formdata.salaryLevelId =  res.value.salaryLevelId
					_that.$refs.autoform.formdata.salaryLevelName =  res.value.salaryLevelName
					_that.getSalaryLeveList()
					_that.$refs.autoform.formdata.probation = res.value.probation
					_that.$refs.autoform.formdata.levelSalaryRange = res.value.levelSalaryRange
					_that.$refs.autoform.formdata.origSalary = res.value.origSalary
					_that.$refs.autoform.formdata.monthSalaryStandard = res.value.monthSalaryStandard
					_that.$refs.autoform.formdata.historyInfo = res.value.historyInfo
					
				})
			}
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key:_that.userCacheKey,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.userId = d.id
							formdata.userName = d.username
							_that.afterUser(d.id)
							uni.removeStorage({
								key:_that.userCacheKey
							})
						}
					}
				})
			}
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							changeEditor("empInfo","userId",{
								link:"../../public/pageSearch/pageSearch",
								"linkParam":{
									other:JSON.stringify({
									}),
									method:"post",
									searchfield: "q",
									url:"tsalaryAdjustMulti/getComboboxAll",
									initload:true,
									namefield:"username",
									cachename:_that.userCacheKey,
									placeholder: "请输入姓名",
								}
							},null,_that.autoformdata)
							_that.getSalaryLeveList()
							}
						}
					})
				}
							
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
